perm filename SAMPLE.TEX[TEX,DEK] blob sn#500226 filedate 1980-04-08 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\input dochdr
C00022 00003
C00028 00004
C00036 00005
C00046 ENDMK
C⊗;
\input dochdr

\secbegin \head{Introduction} \titlepage \runninglefthead{EXAMPLE OF TEXDOC}\setcount0 1
This is a sample ``style sheet'' to illustrate the recommended conventions
desirable for \TEX\ documentation. Explanatory material that has been enclosed
in $\{\{$ and $\}\}$ (like the explanatory material you are now reading)
should be acceptable \TEX\ input; it will be removed from the corresponding
{\:c PASCAL} program produced by {\:c UNDOC}, but it will be typeset in place as
part of the printed documentation produced by {\:c TEXDOC}.
Documentation files like this one have the suffix \.{.DOC}; the {\:c UNDOC} program
converts them into files with suffix \.{.PAS}, and the {\:c TEXDOC} program converts
them into files with suffix \.{.TEX}.
The program segment below is the \\{get_next} procedure, recoded from page 10 of
the original {\:c SAIL} version in file \.{TEXSYN.SAI}. The program conventions have
changed slightly, mainly because \\{inbuf} and \\{curbuf} now are simply
pointers to an ascii array \\{instack}, not variables of type {\bf string}.
Some of the names have changed too; for example, \\{align_insert} has been
substituted for the less appropriate name \\{aligndelim}. The variable
\\{page_warning} is now of type (\\{OK}, \\{def_of}, \\{use_of}). And so on.

\secbegin Here are samples of integer definitions that will cause {\:c UNDOC} to make
corresponding substitutions in the program text:
\pascal
\1\3\2\1\&{define} \\{escape} $≡$ $0\null$\40\ $\{\;$escape delimiter (\.{\\} in \TEX\ manual)$\;\}$
$\null
$
\3\2\1\&{define} \\{lbrace} $≡$ $1\null$\40\ $\{\;$begin block symbol ( \.{\char'173} )$\;\}$
$\null
$
\3\2\1\&{define} \\{rbrace} $≡$ $2\null$\40\ $\{\;$end block symbol ( \.{\char'176} )$\;\}$
$\null
$
\3\2\1\&{define} \\{mathbr} $≡$ $3\null$\40\ $\{\;$math break (  \.{\char'44} )$\;\}$
$\null
$
\3\2\1\&{define} \\{tabmrk} $≡$ $4\null$\40\ $\{\;$tab mark ( \.{\char'26} )$\;\}$
$\null
$
\3\2\1\&{define} \\{carret} $≡$ $5\null$\40\ $\{\;$carriage return or comment ( \.{\char'45} ), \.{\\cr}$\;\}$
$\null
$
\3\2\1\&{define} \\{macprm} $≡$ $6\null$\40\ $\{\;$macro parameter ( \.{\char'43} )$\;\}$
$\null
$
\3\2\1\&{define} \\{supmrk} $≡$ $7\null$\40\ $\{\;$superscript ( \.{\char'136} )$\;\}$
$\null
$
\3\2\1\&{define} \\{submrk} $≡$ $8\null$\40\ $\{\;$subscript ( \.{\char'175} )$\;\}$
$\null
$
\3\2\1\&{define} \\{ignore} $≡$ $9\null$\40\ $\{\;$characters to ignore$\;\}$
$\null
$
\3\2\1\&{define} \\{spacer} $≡$ $10\null$\40\ $\{\;$characters treated as blank space$\;\}$
$\null
$
\3\2\1\&{define} \\{letter} $≡$ $11\null$\40\ $\{\;$characters treated as letters$\;\}$
$\null
$
\3\2\1\&{define} \\{otherchar} $≡$ $12\null$\40\ $\{\;$none of the above character types$\;\}$
$\null
$
\3\2\1\&{define} \\{parend} $≡$ $13\null$\40\ $\{\;$end of paragraph$\;\}$
$\null
$
\3\2\1\&{define} \\{match} $≡$ $14\null$\40\ $\{\;$macro parameter matching$\;\}$
$\null
$
\3\2\1\&{define} \\{charcodes} $≡$ $13\null$\40\ $\{\;$number of distinct character types$\;\}$
$\null
$
\3\2\1\&{define} \\{tokenlist} $≡$ $0\null$\40\ $\{\;$scanning a token list$\;\}$
$\null
$
\3\2\1\&{define} \\{midline} $≡$ $1\null$\40\ $\{\;$scanning a line of characters$\;\}$
$\null
$
\3\2\1\&{define} \\{skipblanks} $≡$ $\\{midline}+\\{charcodes}\null$\40\ $\{\;$like \\{midline} but ignoring blanks$\;\}$
$\null
$
\3\2\1\&{define} \\{newline} $≡$ $\\{skipblanks}+\\{charcodes}\null$\40\ $\{\;$beginning a new line of characters$\;\}$
$\null
$
\3\2\1\&{define} \\{line_feed} $≡$ $\hbox{\char'16}12\null$\40\ $\{\;$end of line in ascii input file$\;\}$
$\null
$
\3\2\1\&{define} \\{form_feed} $≡$ $\hbox{\char'16}14\null$\40\ $\{\;$end of page in ascii input file$\;\}$
$\null
$
\3\2\1\&{define} \\{carriage_return} $≡$ $\hbox{\char'16}15\null$\40\ $\{\;$precedes end of line in ascii input file$\;\}$
$\null
$
\3\2\1\&{define} \\{hashsize} $≡$ $353\null$\40\ $\{\;$hashtable size, must be prime and less than
	$\\{charsize}-127$$\;\}$
$\null
$
\3\2\1\&{define} \\{texpars} $≡$ $10\null$\40\ $\{\;$number of distinct parameters settable by \.{\\chpar}$\;\}$
$\null
$
\3\2\1\&{define} \\{eqtbsize} $≡$ $\\{hashsize}+128+128+\\{texpars}\null$\40\ $\{\;$size of table for current values$\;\}$
$\null
$
\3\2\1\&{define} \\{chartype_offset} $≡$ $\\{hashsize}+128\null$\40\ $\{\;$location of character type in \\{eqtb}$\;\}$
$\null
$
\3\2\1\&{define} \\{tracing_offset} $≡$ $\\{hashsize}+268\null$\40\ $\{\;$location of tracing control in \\{eqtb}$\;\}$
$\null
$
\3\2\1\&{define} \\{param} $≡$ $0\null$\40\ $\{\;$\\{recovery} code for parameters$\;\}$
$\null
$
\3\2\1\&{define} \\{ujlist} $≡$ $1\null$\40\ $\{\;$\\{recovery} code for $u↓j$ lists in alignments$\;\}$
$\null
$
\3\2\1\&{define} \\{vjlist} $≡$ $2\null$\40\ $\{\;$\\{recovery} code for $v↓j$ lists in alignments$\;\}$
$\null
$
\3\2\1\&{define} \\{inserted} $≡$ $3\null$\40\ $\{\;$\\{recovery} code for an inserted token list$\;\}$
$\null
$
\3\2\1\&{define} \\{do_get_next} $≡$ $1\null$\40\ $\{\;$label in \\{get_next} procedure$\;\}$
$\null
$
\3\2\1\&{define} \\{end_get_next} $≡$ $2\null$\40\ $\{\;$label in \\{get_next} procedure$\;\}$
$\null
$
\3\2\1\&{define} \\{inner_switch} $≡$ $3\null$\40\ $\{\;$label in \\{get_next} procedure$\;\}$
$\null
$

\secbegin \head{Data structures}
It isn't clear exactly what types should be declared, but the tentative
types listed below appear in this example. The roles of \\{loc} and \\{recovery}
have been reversed for character files, so that \\{loc} is always of type
\\{integer} and \\{recovery} is always of type \\{inflnk}. The \\{info} field
of \\{recovery} is now set to positive values in all cases, instead of using
conventions like $-l$, etc.
\pascal
\1\3\2\1\&{type} $\\{inflnk}=\mathop{\&{packed }\!}\null$\1\2\&{record} \0$\\{info}\mathrel:0\mathrel{\!.\,.\!}131071$;
\2$\\{link}\mathrel:0\mathrel{\!.\,.\!}32767$\2\&{end}$\null\3
$;
\2$\\{token}=\mathop{\&{packed }\!}\null$\1\2\&{record} \0$\\{cmd}\mathrel:0\mathrel{\!.\,.\!}15$;
\2$\\{chr}\mathrel:0\mathrel{\!.\,.\!}1023$\2\&{end}$\null\3
$;
\2$\\{toklnk}=\mathop{\&{packed }\!}\null$\1\2\&{record} \0$\\{tok}\mathrel:\\{token}$;
\2$\\{link}\mathrel:0\mathrel{\!.\,.\!}32767$\2\&{end}$\null\3
$;
\2$\\{eqtbval}=\mathop{\&{packed }\!}\null$\1\2\&{record} \0$\\{idcmd}\mathrel:0\mathrel{\!.\,.\!}127$;
\2$\\{idlev}\mathrel:0\mathrel{\!.\,.\!}31$;
\2$\\{idlen}\mathrel:0\mathrel{\!.\,.\!}7$;
\2$\\{link}\mathrel:0\mathrel{\!.\,.\!}32767$\2\&{end}$\null\3
$;
\2$\\{tracebits}=\mathop{\&{packed }\!}\null$\1\2\&{record} \0$\\{mmm}\mathrel:0\mathrel{\!.\,.\!}511$;
\2$\\{nnn}\mathrel:0\mathrel{\!.\,.\!}511$;
\2$\\{ddtflag}\mathrel:0\mathrel{\!.\,.\!}1$;
\2$\\{inputflag}\mathrel:0\mathrel{\!.\,.\!}1$;
\2$\\{replflag}\mathrel:0\mathrel{\!.\,.\!}1$;
\2$\\{dumpflag}\mathrel:0\mathrel{\!.\,.\!}1$;
\2$\\{detailflag}\mathrel:0\mathrel{\!.\,.\!}1$;
\2$\\{overflag}\mathrel:0\mathrel{\!.\,.\!}1$\2\&{end}$\null\3
$;
\2$\\{ee}=\null$\1\2\&{record} \0\1\&{case} $1\mathrel{\!.\,.\!}4$ \&{of}
\2\1$1\mathrel:\null$
(\0$\\{eq}\mathrel:\\{eqtbval}$)
\3;
\2\1$2\mathrel:\null$
(\0$\\{int}\mathrel:\\{integer}$)
\3;
\2\1$3\mathrel:\null$
(\0$\\{pts}\mathrel:\\{real}$)
\3;
\2\1$4\mathrel:\null$
(\0$\\{tr}\mathrel:\\{tracebits}$)
\3\3\2\&{end}$\null\3
$;
\2$\\{mm}=\null$\1\2\&{record} \0\1\&{case} $1\mathrel{\!.\,.\!}5$ \&{of}
\2\1$1\mathrel:\null$
(\0$\\{pts}\mathrel:\\{real}$)
\3;
\2\1$2\mathrel:\null$
(\0$\\{int}\mathrel:\\{integer}$)
\3;
\2\1$3\mathrel:\null$
(\0$\\{il}\mathrel:\\{inflnk}$)
\3;
\2\1$4\mathrel:\null$
(\0$\\{tl}\mathrel:\\{toklnk}$)
\3;
\2\1$5\mathrel:\null$
(\0$\\{something_else_probably_too}$)
\3\3\2\&{end}$\null\3
$;
\3\2\1\&{var} $\\{mem}=\mathop{\&{array }}0\mathrel{\!.\,.\!}\\{memsize}-1
\mathop{\&{\ of }\!}
\\{mm}$;
\2$\\{eqtb}=\mathop{\&{array }}0\mathrel{\!.\,.\!}\\{eqtbsize}-
1
\mathop{\&{\ of }\!}
\\{ee}$;


\secbegin Here's an example of a macro with a parameter:
\pascal
\1\3\2\1\&{define} \\{chartype}\.{(\char'43)} $≡$ $\\{eqtb}[\.{\char'43}+\\{chartype_offset}].\\{int}$

\secbegin \head{Input}
The \\{get_next} procedure acts as \TEX's eyes and mouth, as they read and
gobble up source files or stored tokens. The main duty of \\{get_next} is to
input one token, setting \\{curcmd} to the code for the corresponding command
and setting \\{curchar} to the code for the corresponding character. Furthermore,
the value of \\{hashentry} is made nonnegative if and only if the new input token
is a control sequence (and, if so, \\{hashentry} is set to the corresponding
location in \\{eqtb}). Although this procedure has to handle a lot of different
cases, an attempt has been made to keep its inner loop reasonably short and fast.
\pascal
\1\3\2\1\1\&{procedure} $\\{get_next}$;\40\ $\{\;$sends next input token to \\{curcmd} and \\{curchar}$\;\}$
\3\2\1\&{label} \0\\{do_get_next},\45\ \40\ $\{\;$go here to get the next token$\;\}$
\2\\{end_get_next},\45\ \40\ $\{\;$go here when the next token has been got$\;\}$
\2\\{inner_switch};\40\ $\{\;$go here to read the next character$\;\}$
\3\2\1\&{var} $\null$\6Locals for \\{get_next}{ \:m32\7}$\null $
\3\2\&{begin} \2\\{do_get_next}: \0\1\&{if} $\\{state}<>\\{tokenlist}$ \&{then}\40\
$\{\;$Reading from an external file$\;\}$
\2$\null$\6Input from external file, \goto\ \\{end_get_next}
with paragraph end token if end of file, \goto\ \\{do_get_next}
if no input token found{ \:m8\7}$\null 
$\3
\2\&{else} \0$\null$\6Input from token list, \goto\ \\{do_get_next} if end
of list or if a parameter needs to be expanded{ \:m31\7}$\null 
$
;
\2\1\&{if} $\null$\6End of alignment entry sensed?{ \:m6\7}$\null 
$ \&{then}
\0$\null$\6Insert the $\langle v↓j \rangle$ list and \goto\ \\{do_get_next}{ \:m7\7}$\null 
$\3
;
\2\\{end_get_next}: 
\2\&{end}

\secbegin \6End of alignment entry sensed?{ \:m6\7} \.=\par
\pascal
\2$\\{alignstate}=0\mathbin{\&{and}}((\\{curcmd}=\\{tabmrk})\mathbin{\&{or}}(\\{curcmd}=\\{carret})
)
$

\note This code is used in section 5.

\secbegin \6Insert the $\langle v↓j \rangle$ list and \goto\ \\{do_get_next}{ \:m7\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{align_insert}$;
\0$\\{hashentry}\mathrel:=-1$;\40\
$\{\;$this resets \\{hashentry} in case it points to \.{\\cr}$\;\}$
\2$\mathop{\&{goto }\!}\\{do_get_next}$
\2\&{end}

\note This code is used in section 5.

\secbegin \6Input from external file, \goto\ \\{end_get_next}
with paragraph end token if end of file, \goto\ \\{do_get_next}
if no input token found{ \:m8\7} \.=\par
\pascal
\2\1\&{if} $\\{curbuf}<\\{instack_ptr}$ \&{then}\40\
$\{\;$Current line not empty$\;\}$
\2\&{begin} \0$\null$\6Read one character of the input{ \:m9\7}$\null 
$;
\0$\null$\6Change state if necessary, and \goto\ \\{inner_switch}
if the current character should be ignored{ \:m10\7}$\null 
$
\2\&{end}\3
\2\&{else} \1\&{begin} \0$\null$\6Move to next line of file, or \goto\ \\{end_get_next}
with paragraph end token if end of file, or \goto\
\\{do_get_next} if inserted list just ended{ \:m22\7}$\null 
$;
\0$\mathop{\&{goto }\!}\\{inner_switch}$
\2\&{end}\3


\note This code is used in section 5.

\secbegin \6Read one character of the input{ \:m9\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{curchar}\mathrel:=\\{ord}(\\{instack}[\\{instack_ptr}])
$;
\0$\\{instack_ptr}\mathrel:=\\{instack_ptr}+1$;
\0$\\{curcmd}\mathrel:=\\{chartype}(\\{curchar})$
\2\&{end}

\note This code is used in section 8.

\secbegin \6Change state if necessary, and \goto\ \\{inner_switch}
if the current character should be ignored{ \:m10\7} \.=\par
\pascal
\2\1\&{case} $\\{state}+\\{curcmd}$ \&{of}
\2\1\6Cases where character is ignored{ \:m11\7}: \0$\mathop{\&{goto }\!}\\{inner_switch}$\3;
\2\1\6Cases involving an escape character{ \:m12\7}: \0$\null$\6Scan a control sequence{ \:m14\7}$\null $\3;
\2\1\6Handle situations involving spaces, braces, changes
of state{ \:m15\7}\3;
\2\1\\{others}: \0$\null$\6Do nothing{ \:m13\7}$\null $\3
\2\&{end}\3

\note This code is used in section 8.


\secbegin \6Cases where character is ignored{ \:m11\7} \.=\par
\pascal
\2$\\{midline}+\\{ignore},\45\\{skipblanks}+\\{ignore}
,\45\\{skipblanks}+\\{spacer},\45\\{newline}+\\{ignore}
,\45\\{newline}+\\{spacer}$

\note This code is used in section 10.

\secbegin \6Cases involving an escape character{ \:m12\7} \.=\par
\pascal
\2$\\{midline}+\\{escape},\45\\{skipblanks}+\\{escape}
,\45\\{newline}+\\{escape}$

\note This code is used in section 10.

\secbegin \6Do nothing{ \:m13\7} \.=\par

\note This code is used in sections 10, 31,  and 36.

\secbegin \6Scan a control sequence{ \:m14\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{control_seq}$;
\2\1\&{with} $\\{eqtb}[\\{hashentry}].\\{eq}$ \&{do}
\2\&{begin} \0$\\{curcmd}\mathrel:=\\{idcmd}$;
\0$\\{curchar}\mathrel:=\\{link}$
\2\&{end}\3
;
\2$\\{state}\mathrel:=\\{skipblanks}$
\2\&{end}

\note This code is used in section 10.

\secbegin \6Handle situations involving spaces, braces, changes
of state{ \:m15\7} \.=\par
\pascal
\2$\\{midline}+\\{spacer}\mathrel:\null$\6Set \\{skipblanks} state and emit a space{ \:m16\7}$\null 
$;
\2$\\{midline}+\\{carret}\mathrel:\null$\6Set \\{newline} state and emit a space{ \:m17\7}$\null 
$;
\2$\\{skipblanks}+\\{carret}\mathrel:\null$\6Set \\{newline} state and \goto\ \\{inner_switch}{ \:m18\7}$\null 
$;
\2$\\{midline}+\\{lbrace}\mathrel:\\{alignstate}\mathrel:
=\\{alignstate}+1$;
\2$\\{skipblanks}+\\{lbrace},\45\\{newline}+\\{lbrace}
\mathrel:\null$\6Set \\{midline} state and increase \\{alignstate}{ \:m20\7}$\null 
$;
\2$\\{midline}+\\{rbrace}\mathrel:\\{alignstate}\mathrel:
=\\{alignstate}-1$;
\2$\\{skipblanks}+\\{rbrace},\45\\{newline}+\\{rbrace}
\mathrel:\null$\6Set \\{midline} state and decrease \\{alignstate}{ \:m21\7}$\null 
$;
\2$\null$\6Situations leading to \\{midline} state{ \:m19\7}$\null 
\mathrel:\\{state}\mathrel:=\\{midline}
$

\note This code is used in section 10.

\secbegin \6Set \\{skipblanks} state and emit a space{ \:m16\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{state}\mathrel:=\\{skipblanks}$;
\0$\\{curchar}\mathrel:=\\{ord}(\.{'\ '})$
\2\&{end}

\note This code is used in section 15.

\secbegin \6Set \\{newline} state and emit a space{ \:m17\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{state}\mathrel:=\\{newline}$;
\0$\\{curbuf}\mathrel:=\\{instack_ptr}$;\40\
$\{\;$empty the buffer$\;\}$
\2$\\{curcmd}\mathrel:=\\{spacer}$;
\0$\\{curchar}\mathrel:=\\{ord}(\.{'\ '})$
\2\&{end}

\note This code is used in section 15.

\secbegin \6Set \\{newline} state and \goto\ \\{inner_switch}{ \:m18\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{state}\mathrel:=\\{newline}$;
\0$\\{curbuf}\mathrel:=\\{instack_ptr}$;\40\
$\{\;$empty the buffer$\;\}$
\2$\mathop{\&{goto }\!}\\{inner_switch}$
\2\&{end}

\note This code is used in section 15.

\secbegin \6Situations leading to \\{midline} state{ \:m19\7} \.=\par
\pascal
\2$\\{skipblanks}+\\{mathbr},\45\\{skipblanks}+\\{tabmrk}
,\45\\{skipblanks}+\\{macprm},\45\\{skipblanks}
+\\{supmrk},\45\\{skipblanks}+\\{submrk},\45\\{skipblanks}
+\\{letter},\45\\{skipblanks}+\\{otherchar}
,\45\\{newline}+\\{mathbr},\45\\{newline}+\\{tabmrk}
,\45\\{newline}+\\{macprm},\45\\{newline}+
\\{letter},\45\\{newline}+\\{otherchar}$

\note This code is used in section 15.

\secbegin \6Set \\{midline} state and increase \\{alignstate}{ \:m20\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{state}\mathrel:=\\{midline}$;
\0$\\{alignstate}\mathrel:=\\{alignstate}+1$
\2\&{end}

\note This code is used in section 15.


\secbegin \6Set \\{midline} state and decrease \\{alignstate}{ \:m21\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{state}\mathrel:=\\{midline}$;
\0$\\{alignstate}\mathrel:=\\{alignstate}-1$
\2\&{end}

\note This code is used in section 15.

\secbegin \6Move to next line of file, or \goto\ \\{end_get_next}
with paragraph end token if end of file, or \goto\
\\{do_get_next} if inserted list just ended{ \:m22\7} \.=\par
\pascal
\1\3\2\&{begin} \0\1\&{if} $\\{filename}<>0$ \&{then}\40\
$\{\;$Reading from a character file$\;\}$
\2$\null$\6Read next line into input buffer{ \:m23\7}$\null 
$\3
\2\&{else} \0\1\&{if} $\\{inptr}<>0$ \&{then}\40\
$\{\;$Input was text inserted by user during error recovery$\;\}$
\2\&{begin} \0$\\{popinput}$;\40\
$\{\;$Restore previous input source$\;\}$
\2$\mathop{\&{goto }\!}\\{do_get_next}$
\2\&{end}\3
\2\&{else} \0$\null$\6Input online from terminal into input buffer{ \:m27\7}$\null 
$
;
\2$\\{curbuf}\mathrel:=\\{inbuf}\null$\40\ $\{\;$Prepare to scan input buffer$\;\}$
$\null
$
\2\&{end}

\note This code is used in section 8.

\secbegin \6Read next line into input buffer{ \:m23\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{inputln}$;\40\
$\{\;$Read current file up to line feed or form feed or eof$\;\}$
\2\1\&{if} $\\{eoff}$ \&{then}
\0$\null$\6Process end of file and \goto\ \\{end_get_next} with
\\{parend}{ \:m24\7}$\null 
$\3
;
\2$\null$\6Trace the input line if requested{ \:m26\7}$\null 
$;
\0$\null$\6Advance line and page number{ \:m30\7}$\null 
$
\2\&{end}

\note This code is used in section 22.

\secbegin \6Process end of file and \goto\ \\{end_get_next} with
\\{parend}{ \:m24\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{write}(\.{')'})$;\40\
$\{\;$Show user that the file has been read$\;\}$
\2$\\{release}(\\{loc})$;\40\
$\{\;$Close the file$\;\}$
\2$\null$\6Check if end of page is {\:c OK}{ \:m25\7}$\null 
$;
\0$\\{popinput}$;\40\
$\{\;$Restore previous status$\;\}$
\2$\\{curcmd}\mathrel:=\\{parend}$;
\0$\\{curchar}\mathrel:=0$;
\0$\mathop{\&{goto }\!}\\{end_get_next}$
\2\&{end}

\note This code is used in section 23.

\secbegin \6Check if end of page is {\:c OK}{ \:m25\7} \.=\par
\pascal
\2\1\&{if} $\\{page_warning}<>\\{OK}$ \&{then}
\0$\\{page_end_error}$\3


\note This code is used in sections 24 and 30.

\secbegin \6Trace the input line if requested{ \:m26\7} \.=\par
\pascal
\2\1\&{if} $\\{eqtb}[\\{trace_offset}].\\{tr}.\\{inputflag}$ \&{then}
\2\&{begin} \0$\\{println}$;
\2\1\&{for} $\\{curbuf}\mathrel:=\\{inbuf}\mathrel{\&{to}}\\{instack_ptr}
-1$ \&{do}
\0$\\{write}(\\{instack}[\\{curbuf}])$\3
;
\2$\null$\6Input online from terminal into input buffer{ \:m27\7}$\null 
$;
\2\&{end}\3


\note This code is used in section 23.

\secbegin \6Input online from terminal into input buffer{ \:m27\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{println}$;
\0$\\{print}(\.{'*'})$;\40\
$\{\;$prompt the user$\;\}$
\2$\\{inputln}$;
\0$\null$\6Echo the input on the output file{ \:m28\7}$\null 
$;
\0$\null$\6Define the escape character if the first character
has just been read{ \:m29\7}$\null 
$;
\2\&{end}

\note This code is used in sections 22 and 26.

\secbegin \6Echo the input on the output file{ \:m28\7} \.=\par
\pascal
\2\1\&{for} $\\{curbuf}\mathrel:=\\{inbuf}\mathrel{\&{to}}\\{instack_ptr}
-1$ \&{do}
\0$\\{write}(\\{instack}[\\{curbuf}])$\3


\note This code is used in section 27.

\secbegin \6Define the escape character if the first character
has just been read{ \:m29\7} \.=\par
\pascal
\2\1\&{if} $(\\{escapechar}<0)\mathbin{\&{and}}(\\{ord}(\\{instack}[\\{inbuf}])<>\\{carriage_return}
)
$ \&{then}
\2\&{begin} \0$\\{escapechar}\mathrel:=\\{ord}(\\{instack}[\\{inbuf}])
$;
\0$\\{chartype}(\\{escapechar})\mathrel:=\\{escape}$;
\2\&{end}\3


\note This code is used in section 27.

\secbegin \6Advance line and page number{ \:m30\7} \.=\par
\pascal
\2\1\&{with} $\\{recovery}$ \&{do}
\2\1\&{if} $\\{brchar}=\\{form_feed}$ \&{then}\40\
$\{\;$End of page$\;\}$
\2\&{begin} \0$\\{info}\mathrel:=\\{info}+1$;\40\
$\{\;$advance page number$\;\}$
\2$\\{print}(\.{'\ '})$;
\0$\\{print}(\\{info})$;\40\
$\{\;$print progress report for user$\;\}$
\2$\\{link}\mathrel:=0$;\40\
$\{\;$set line number zero$\;\}$
\2$\null$\6Check if end of page is {\:c OK}{ \:m25\7}$\null 
$
\2\&{end}\3
\2\&{else} \0$\\{link}\mathrel:=\\{link}+1\null$\40\ $\{\;$advance line number$\;\}$
$\null
$
\3


\note This code is used in section 23.


\secbegin \6Input from token list, \goto\ \\{do_get_next} if end
of list or if a parameter needs to be expanded{ \:m31\7} \.=\par
\pascal
\2\1\&{if} $\\{loc}<>0$ \&{then}\40\
$\{\;$Current token list is not empty$\;\}$
\2\&{begin} \0$\null$\6Read next token from token list{ \:m33\7}$\null 
$;
\2\1\&{case} $\\{curcmd}$ \&{of}
\2\10: \0$\null$\6Process a control sequence token{ \:m34\7}$\null 
$\3;
\2\1\\{outpar}: \0$\null$\6Insert a macro parameter and \goto\ \\{do_get_next}{ \:m35\7}$\null 
$\3;
\2\1\\{lbrace}: \0$\\{alignstate}\mathrel:=\\{alignstate}+1$\3;
\2\1\\{rbrace}: \0$\\{alignstate}\mathrel:=\\{alignstate}-1$\3;
\2\1\\{others}: \0$\null$\6Do nothing{ \:m13\7}$\null $\3
\2\&{end}\3
\2\&{end}\3
\2\&{else} \1\&{begin} \0$\null$\6Process end of token list{ \:m36\7}$\null $;
\0$\\{popinput}$;\40\
$\{\;$Return to previous level of input$\;\}$
\2$\mathop{\&{goto }\!}\\{do_get_next}$
\2\&{end}\3


\note This code is used in section 5.

\secbegin \6Locals for \\{get_next}{ \:m32\7} \.{+=}\par
\pascal
\2$\\{t}\mathrel:\\{token}$;\40\ $\{\;$packed token stored in a token list$\;\}$
\2$\\{tt}\mathrel:\\{toklnk}$;\40\ $\{\;$packed token and link stored in a token list$\;\}$


\note This code is used in section 5.

\secbegin \6Read next token from token list{ \:m33\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{tt}\mathrel:=\\{mem}[\\{loc}].\\{tl}$;
\2\1\&{with} $\\{tt}$ \&{do}
\2\&{begin} \0$\\{t}\mathrel:=\\{tok}$;\40\
$\{\;$get token to emit$\;\}$
\2$\\{loc}\mathrel:=\\{link}$;\40\
$\{\;$advance to next element of token list$\;\}$
\2$\\{curchar}\mathrel:=\\{t}.\\{chr}$;
\0$\\{curcmd}\mathrel:=\\{t}.\\{cmd}$;
\2\&{end}\3
\2\&{end}

\note This code is used in section 31.

\secbegin \6Process a control sequence token{ \:m34\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{hashentry}\mathrel:=\\{curchar}$;
\2\1\&{with} $\\{eqtb}[\\{curchar}].\\{eq}$ \&{do}
\2\&{begin} \0$\\{curcmd}\mathrel:=\\{idcmd}$;
\0$\\{curchar}\mathrel:=\\{link}$
\2\&{end}\3
\2\&{end}

\note This code is used in section 31.

\secbegin \6Insert a macro parameter and \goto\ \\{do_get_next}{ \:m35\7} \.=\par
\pascal
\1\3\2\&{begin} \0$\\{pushinput}$;\40\
$\{\;$Begin a new level of input$\;\}$
\2\1\&{with} $\\{recovery}$ \&{do}
\2\&{begin} \0$\\{loc}\mathrel:=\\{parstack}[\\{link}+\\{curchar}]
$;\40\
$\{\;$Beginning of the parameter$\;\}$
\2$\\{info}\mathrel:=\\{param}$;
\0$\\{link}\mathrel:=\\{loc}$;\40\
$\{\;$\\{recovery} convention for parameter token list$\;\}$
\2$\mathop{\&{goto }\!}\\{do_get_next}\null$\40\ $\{\;$The state remains equal to \\{tokenlist}$\;\}$
$\null
$
\2\&{end}\3
\2\&{end}

\note This code is used in section 31.

\secbegin \6Process end of token list{ \:m36\7} \.=\par
\pascal
\2\1\&{case} $\\{recovery}.\\{info}$ \&{of}
\2\1\\{param},\45\ \\{vjlist}: \0$\null$\6Do nothing{ \:m13\7}$\null $\3;
\2\1\\{ujlist}: \0$\\{alignstate}\mathrel:=0$\3;\40\
$\{\;$$u↓j$ list of an alignment has just ended$\;\}$
\2\1\\{inserted}: \0$\\{dslist}(\\{recovery})$\3;\40\
$\{\;$Destroy a temporarily inserted list$\;\}$
\2\1\\{others}: \0$\null$\6Process end of macro body{ \:m37\7}$\null $\3
\2\&{end}\3

\note This code is used in section 31.

\secbegin \6Process end of macro body{ \:m37\7} \.=\par
\pascal
\2\1\&{with} $\\{recovery}$ \&{do}
\2\&{begin} \0$\\{delrclink}(\\{info})$;\40\
$\{\;$Dereference the macro body$\;\}$
\2\1\&{while} $\\{parptr}>\\{link}$ \&{do}
\2\&{begin} \0$\\{parptr}\mathrel:=\\{parptr}-1$;
\0$\\{dslist}(\\{parstack}[\\{parptr}])\null$\40\ $\{\;$Destroy each parameter$\;\}$
$\null
$
\2\&{end}\3
\2\&{end}\3


\note This code is used in section 36.

\index
\\OK:25.
\\align_insert:7.
\\alignstate:6, 15, 20, 21, 31, 36.
\\brchar:30.
\\carret:\&{2}, 6, 15.
\\carriage_return:\&{2}, 29.
\\charcodes:\&{2}, 2.
\\chartype_offset:\&{2}, 4.
\#chartype:\&{4}, 9, 29.
\\chr:3, 33.
\\cmd:3, 33.
\\control_seq:14.
\\curbuf:8, 17, 18, 22, 26, 28.
\\curchar:9, 14, 16, 17, 24, 33, 34, 35.
\\curcmd:6, 9, 10, 14, 17, 24, 31, 33, 34.
\\ddtflag:3.
\\delrclink:37.
\\detailflag:3.
\\do_get_next:\&{2}, 5, 7, 22, 31, 35.
\\dslist:36, 37.
\\dumpflag:3.
\\ee:3.
\\end_get_next:\&{2}, 5, 24.
\\eoff:23.
\\eqtbsize:\&{2}, 3.
\\eqtbval:3.
\\eqtb:3, 4, 14, 26, 34.
\\eq:3, 14, 34.
\\escapechar:29.
\\escape:\&{2}, 12, 29.
\\filename:22.
\\form_feed:\&{2}, 30.
\\get_next:5.
\\hashentry:7, 14, 34.
\\hashsize:\&{2}, 2.
\\idcmd:3, 14, 34.
\\idlen:3.
\\idlev:3.
\\ignore:\&{2}, 11.
\\il:3.
\\inbuf:22, 26, 28, 29.
\\inflnk:3.
\\info:3, 30, 35, 36, 37.
\\inner_switch:\&{2}, 5, 8, 10, 18.
\\inptr:22.
\\inputflag:3, 26.
\\inputln:23, 27.
\\inserted:\&{2}, 36.
\\instack_ptr:8, 9, 17, 18, 26, 28.
\\instack:9, 26, 28, 29.
\\integer:3.
\\int:3, 4.
\\lbrace:\&{2}, 15, 31.
\\letter:\&{2}, 19.
\\link:3, 14, 30, 33, 34, 35, 37.
\\loc:24, 31, 33, 35.
\\macprm:\&{2}, 19.
\\mathbr:\&{2}, 19.
\\memsize:3.
\\mem:3, 33.
\\midline:\&{2}, 2, 11, 12, 15, 20, 21.
\\mmm:3.
\\mm:3.
\\newline:\&{2}, 11, 12, 15, 17, 18, 19.
\\nnn:3.
\\ord:9, 16, 17, 29.
\\otherchar:\&{2}, 19.
\\others:10, 31, 36.
\\outpar:31.
\\overflag:3.
\\page_end_error:25.
\\page_warning:25.
\\param:\&{2}, 35, 36.
\\parend:\&{2}, 24.
\\parptr:37.
\\parstack:35, 37.
\\popinput:22, 24, 31.
\\println:26, 27.
\\print:27, 30.
\\pts:3.
\\pushinput:35.
\\rbrace:\&{2}, 15, 31.
\\real:3.
\\recovery:30, 35, 36, 37.
\\release:24.
\\replflag:3.
\\skipblanks:\&{2}, 2, 11, 12, 14, 15, 16, 19.
\\something_else_probably_too:3.
\\spacer:\&{2}, 11, 15, 17.
\\state:5, 10, 14, 15, 16, 17, 18, 20, 21.
\\submrk:\&{2}, 19.
\\supmrk:\&{2}, 19.
\\tabmrk:\&{2}, 6, 19.
\\texpars:\&{2}, 2.
\\tl:3, 33.
\\tokenlist:\&{2}, 5.
\\token:3, 32.
\\toklnk:3, 32.
\\tok:3, 33.
\\trace_offset:26.
\\tracebits:3.
\\tr:3, 26.
\\tt:32, 33.
\\t:32, 33.
\\ujlist:\&{2}, 36.
\\vjlist:\&{2}, 36.
\\write:24, 26, 28.
\endindex